package common.sample;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.LinearLayout;

import com.tekj.cxqcb.R;
import com.just.agentweb.AgentWeb;
import com.just.agentweb.DefaultWebClient;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * AgentWeb 测试
 * Created by JustTong
 */
public class TestAgentWebActivity extends AppCompatActivity {

    @BindView(R.id.ll_main)
    LinearLayout llMain;

    private AgentWeb mAgentWeb;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_agent_web);
        ButterKnife.bind(this);

        mAgentWeb = AgentWeb.with(this)
                .setAgentWebParent(llMain, new LinearLayout.LayoutParams(-1, -1))
                .useDefaultIndicator()
                .setOpenOtherPageWays(DefaultWebClient.OpenOtherPageWays.ASK)//打开其他应用时，弹窗咨询用户是否前往其他应用
                .createAgentWeb()
                .ready()
                .go("http://jd.com");

//        mAgentWeb = AgentWeb.with(this)
//                .setAgentWebParent(llMain, new LinearLayout.LayoutParams(-1, -1))
//                .useDefaultIndicator()
////                    .setWebChromeClient(mWebChromeClient)
////                      .setWebViewClient(mWebViewClient)
//                .setMainFrameErrorView(R.layout.agentweb_error_page, -1)
//                .setSecurityType(AgentWeb.SecurityType.STRICT_CHECK)
////                 .setWebLayout(new WebLayout(this))
//                .setOpenOtherPageWays(DefaultWebClient.OpenOtherPageWays.ASK)//打开其他应用时，弹窗咨询用户是否前往其他应用
//                .interceptUnkownUrl() //拦截找不到相关页面的Scheme
//                .createAgentWeb()
//                .ready()
//                .go("http://jd.com");

    }


    @Override
    protected void onPause() {
        mAgentWeb.getWebLifeCycle().onPause();
        super.onPause();

    }


    @Override
    protected void onResume() {
        mAgentWeb.getWebLifeCycle().onResume();
        super.onResume();
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        //mAgentWeb.destroy();
        mAgentWeb.getWebLifeCycle().onDestroy();
    }

}
